home *** CD-ROM | disk | FTP | other *** search
- #pragma once
- /*
- File: SimpleParseUtils.h
-
- Contains: Utilities for useful for very simple
- parsing tasks.
-
- Version: 1.0.3 (for System 7.x)
-
- Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
- */
-
- static const unsigned char *whiteSpaces = "\p \t\r\n";
- static const unsigned char *tokenBreaks = "\p{}[]();"; // these are both wordbreaks and tokens
- static const unsigned char *quoteBreaks = "\p\"\'‘’“”";
- static const unsigned char *wordBreaks = "\p \t\r\n~$%+-*/:;,(){}#[]~`\\'\"!\0";
- static const unsigned char *wordBreaksNoWhiteSpace = "\p$%+-*/:;,{}#[]~`\\'\"!\0";
- static const unsigned char *alphaBreaks = "\pabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$%+-*/:;,{}#[]~`\\'\"!\0";
- static const unsigned char *endLines = "\p\r\n";
- static const unsigned char *lineBreaks = "\p\r\n";
-
- // * if inMem points to a the same string as inString, true
- Boolean StrEquals(const unsigned char *inString, char *inMem);
-
- // * if inMem points to a the same string as inString followed by whitespace, true
- Boolean StrEqualsToken(const unsigned char *inString, char *inMem);
-
- // * if inMem points to a the same string as inString followed by whitespace, true
- Boolean PtrEqualsToken(const Ptr inString, char *inMem);
-
- // * if inMem points to a char which is in inString, true
- Boolean StrEqualsChars(const unsigned char *inString, char *inMem);
-
- // * count whitespace chars
- long CountWhiteSpace(char *inMem, long inLength);
-
- // * return a pascal string containing the next token
- StringPtr GetTokenString(char *inMem, long inLength);
-
- // * return a length-unlimited string containing the next token
- Ptr GetTokenPtr(char *inMem, long inLength);
-
- // * return a token with a custom delimiting string
- Ptr GetDelimitedToken(const unsigned char *inDelimiter, char *inMem, long inLength);
-
- // * return the char in inString actually found
- short FindSelectChar(const unsigned char *inString, char *inMem, long inLength);
-
- // * look for inFindChar until either we hit a char in inUntil or index >= inLength
- Boolean FindCharUntil(short inFindChar, const unsigned char *inUntil, char *inMem, long inLength);
-
- // * get all text from inMem to end of line
- Ptr GetEntireLine(char *inMem, long inLength);
-
- // * for checking dot extensions (.c .h .pas .r, etc)
- Boolean StringHasExtension(const unsigned char * inExtension, const unsigned char *inString);
-
- // * append a pstring to the given Ptr
- void PtrAppendStr(Ptr inDestPtr, unsigned char *inStringToAppend);
-
- // * strip all but one space from contiguous runs of whitespace; can shrink inDestPtr
- void CollapsePtrWhiteSpace(Ptr inDestPtr);
-
- // * add a .dot extension to a Mac filename (yuk!)
- void AddDotExtension(const Str255 inString, const Str255 inDot, Str255 outString);
-
-